<template>
  <div class="app-container">
    <eHeader :param-bean="paramBean" :sup_this="sup_this" />
    <eForm ref="form" :sup_this="sup_this" />
    <!--表格渲染-->
    <DataGridTable
      v-loading="loading"
      ref="mainTable"
      :sup_this="sup_this"
      :data="data.rtnList"
      :total="total"
      :show-cell-class="true"
      :show-row-complex-number="true"
      :all-define-columns="['flowKey','flowName','selfStateName','lastUpdateDate','rmk']"
      grid-id="workflowConfigMngMainGridId"
      @toViewHistory="toViewHistory"
      @selection-change="handleGridSelectionChange">
      <el-table-column :show-overflow-tooltip="true" prop="funProcessName" label="业务类型" width="150px">
        <template slot-scope="scope">
          <edit :data="scope.row" :sup_this="sup_this" />
        </template>
      </el-table-column>
      <el-table-column slot="flowKey" prop="flowKey" label="流程Key"/>
      <el-table-column slot="flowName" prop="flowName" label="流程名称"/>
      <el-table-column slot="selfStateName" prop="selfStateName" label="状态"/>
      <el-table-column slot="lastUpdateDate" :show-overflow-tooltip="true" prop="lastUpdateDate" label="更新日期">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.lastUpdateDate) }}</span>
        </template>
      </el-table-column>
      <el-table-column v-if="checkPermission(['SYS_ADMIN','COMMON_ADMIN','WORKFLOW_CONFIG_ALL','WORKFLOW_CONFIG_CHANGE','WORKFLOW_CONFIG_CREATE'])" label="操作" width="220px" align="center">
        <template slot-scope="scope">
          <el-button v-if="scope.row.funProcess !== '40'" type="primary" size="mini" @click="userSetting(scope.row)">人员设置</el-button>
        </template>
      </el-table-column>
      <el-table-column slot="rmk" :show-overflow-tooltip="true" prop="rmk" label="备注"/>
    </DataGridTable>
    <historyList ref="historyList" :sup_this="sup_this" />
    <flowImageSet ref="flowImageSet" :sup_this="sup_this" :click_enable="true" />
  </div>
</template>

<script>
import { parseTime } from '@/utils/index'
import checkPermission from '@/utils/permission'
import initData from '@/mixins/initData'
import { loadDataUrl } from '@/api/system/workflowConfig'
import eHeader from './module/header'
import eForm from './module/form'
import edit from './module/edit'
import flowImageSet from '@/views/system/workflow/workflowDef/module/flowImageSet'
import historyList from './module/historyList'

export default {
  components: { eHeader, edit, eForm, historyList, flowImageSet },
  mixins: [initData],
  data() {
    return {
      delLoading: false,
      sup_this: this
    }
  },
  created() {
    this.url = loadDataUrl()
    this.$nextTick(() => {
      this.init()
    })
  },
  methods: {
    parseTime,
    checkPermission,
    beforeInit() {
      return true
    },
    userSetting(row) {
      const _this = this.$refs.flowImageSet
      _this.flowKey = row.flowKey
      _this.configMngData = row
      _this.initDisplayInfo(row.flowKey, '')
      _this.dialog = true
    },
    toViewHistory(row) {
      this.openViewHistory(row, 'historyList')
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss">
  .role-span {
    font-weight: bold;color: #303133;
    font-size: 15px;
  }
</style>
